package com.health.streadcard;

import android.app.Activity;
import android.text.TextUtils;

import cn.com.senter.helper.ShareReferenceSaver;

/**
 * Created by Administrator on 2019/3/2.
 */

public class ServerData {
    
    /**
     * 获取Ip
     *
     * @param activity
     * @return
     */
    public static String getCurrentServerAddress(Activity activity) {
        String index = ShareReferenceSaver.getData(activity, "CN.COM.SENTER.SelIndex");
        if (TextUtils.isEmpty(index)) {
            index = "0";
        }
        String ip = ShareReferenceSaver.getData(activity, "CN.COM.SENTER.SERVER_KEY" + (Integer.parseInt(index) + 1));
        if (TextUtils.isEmpty(ip)) {
            ip = "senter-online.cn";
        }
        return ip;
    }
    
    /**
     * 获取端口
     *
     * @param activity
     * @return
     */
    public static String getCurrentServerPort(Activity activity) {
        String index = ShareReferenceSaver.getData(activity, "CN.COM.SENTER.SelIndex");
        if (TextUtils.isEmpty(index)) {
            index = "0";
        }
        String port = ShareReferenceSaver.getData(activity, "CN.COM.SENTER.PORT_KEY" + (Integer.parseInt(index) + 1));
        if (TextUtils.isEmpty(port)) {
            port = "10002";
        }
        return port;
    }
    
}
